<template>
  <div>
    <div class="text item" style="text-align: center;">
      <span class="showTextForMat"><span style="font-weight: bold; text-align: center;font-size: 16px;">{{ form.shareTitle }}</span></span>
    </div>
    <div class="text item">
      <span class="showTextForMat">{{ $t('过期时间') }}: {{ judgmentTime() }}</span>
    </div>
    <div class="text item">
      <span class="showTextForMat">{{ $t('分享链接') }}: <br>{{ form.url }}</span>
    </div>
    <div class="text item">
      <span class="showTextForMat">{{ $t('消息发自') }}: <br>{{ systemName }}</span>
    </div>
    <div slot="header" class="clearfix" style="text-align: center;">
      <el-button
        v-clipboard:copy="form.shareTitle + '\n' + $t('过期时间') + ': ' + judgmentTime() + '\n' + $t('分享链接') + ': ' + form.url + '\n\n' + $t('消息发自') + ': ' + systemName"
        v-clipboard:success="onCopy"
        v-clipboard:error="onError"
        type="primary"
        size="mini"
      >{{ $t('复制信息') }}</el-button>
    </div>
  </div>
</template>

<script>
// import { getConfigKey } from '@/api/system/config'

export default {
  data() {
    return {
      form: {},
      copyText: '',
      systemName: this.$t('J博士投资管理系统')
    }
  },
  created() {
    // 获取系统变量当前系统名称
    // getConfigKey('productName').then(response => {
    //   this.systemName = response.msg
    //   if (this.systemName) {
    //     this.systemName = this.systemName.trim()
    //   }
    // })
  },
  methods: {
    init(data) {
      this.form = data
    },
    judgmentTime() {
      const resultTime = this.form.aging === null ? this.$t('长期有效') : this.parseTime(this.form.aging, '{y}-{m}-{d} {h}:{i}:{s}')
      console.log(resultTime)
      return resultTime
    },
    onCopy() {
      this.msgSuccess(this.$t('复制成功!'))
      this.$parent.$parent.shareUrlMsgOpen = false
    },
    onError() {
      this.msgError(this.$t('复制失败!'))
    },
    formatYesNo(val) {
      if (val === 'Y') {
        return '是'
      } else {
        return '否'
      }
    }
  }
}
</script>

<style scoped>
.text {
  font-size: 14px;
}
.item {
  margin-bottom: 18px;
}
.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both
}
.box-card {
  width: 480px;
}
</style>
